#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>

using namespace std;

int main (int argc, char* argv[])
{
	int Issues = 0;
	if (argc > 1)
	{
		cout << "File Loaded!" << endl;
		cout << "Loading Dictionary..." << endl;
		string Dictionary;
		string DBuffer;
		ifstream DIn;
		DIn.open("Dictionary.txt", ios::in);
		if (DIn.is_open())
		{
			while (getline(DIn, DBuffer))
				Dictionary += (DBuffer + '\n');
		}
		else
		{
			cout << "ERROR: Dictionary could not be loaded!" << endl << endl;
			system("pause");
		}
		cout << "Dictionary Loaded!" << endl;
		cout << "Spell Checking..." << endl;
		ifstream In;
		In.open(argv[1], ios::in);
		string Word;
		if (In.is_open())
		{
			while (In >> Word)
			{
				char Tokens[] = "()/\"\'!@#$%^&*-+=,.?`~[]{}";
				for (unsigned int i = 0; i < strlen(Tokens); i++)
				{
					Word.erase(remove(Word.begin(), Word.end(), Tokens[i]), Word.end());
				}
				transform(Word.begin(), Word.end(), Word.begin(), tolower);
				unsigned Found = Dictionary.find(Word);
				if (Found != string::npos)
				{

				}
				else
				{
					Issues++;
				}
			}
		}
		else
		{
			cout << "ERROR: Unable to open file!" << endl << endl;
			system("pause");
		}
		In.close();
		cout << "Spell Check Complete!" << endl << endl;
		cout << Issues;
		cout << " Issues Found!" << endl << endl;
		system("pause");
	}
	else
	{
		cout << "ERROR: No file!" << endl << endl;
		system("pause");
	}
}